#include "surface_image.h"

extern const char chargement_image[] = "Impossible de charger l'image";
 
SDL_Surface *surface_image::charger_image(std::string nom) throw(erreur) {
	SDL_Surface *s = IMG_Load(nom.c_str());
    SDL_Surface *s_alpha;
	if(!s)
		throw une_erreur<chargement_image>();
    s_alpha = SDL_DisplayFormatAlpha(s);
    SDL_FreeSurface(s);
    if(!s_alpha)
        throw une_erreur<chargement_image>();
    
	return s_alpha;
}

void surface_image::changer(std::string fichier) throw(erreur) {
	surface_ = charger_image(fichier);
	module_interface::instance().demander_rafraichir();
}
